﻿using CSharpDay12Nov10.Adapters.Adapters;
using CSharpDay12Nov10.Adapters.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Microsoft.AspNet.Identity; //for getUserId
using CSharpDay12Nov10.Models;

namespace CSharpDay12Nov10.Controllers
{
    [Authorize]
    public class apiTaskController : ApiController
    {
        ITaskAdapter _adapter;
        public apiTaskController()
        {
            _adapter = new TaskAdapter();
        }
        public apiTaskController(ITaskAdapter adapter)
        {
            _adapter = adapter;
        }

        public IHttpActionResult Get()
        {
            string userId = User.Identity.GetUserId(); //gets current user id from token
            List<ToDoVM> model = _adapter.GetAllTasks(userId);
            return Ok(model);
        }
    }
}
